package thread;

public class RunableDemo implements Runnable {
	private Ticks ticks=new Ticks();

	@Override
	public void run() {
		int b =0;
         
		while (true) {
			synchronized (ticks) {
				if (ticks.getT() <= 0)
					break;
				ticks.sail();
			}
			b++;
			                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
			
			
		}
		System.out.println("我是" + Thread.currentThread().getName() + "售出" + b+ "张");
	}
}

	class Ticks{
	private int t=100;

	public int getT() {
		return t;
	}
	public void sail(){
		t--;
		
	}
		
	}
	
